package cn.usts.edu.lesson04;



import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UdpServerDemo01 {
    public static void main(String[] args) throws Exception {
        // 发放端口
        DatagramSocket socket = new DatagramSocket(9999);
        // 接收数据
        byte[] buffer = new byte[1024];
        DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);
        // 接收
        socket.receive(packet);
        // 输出
        System.out.println(new String(packet.getData(), 0, packet.getLength()));
        // 关闭
        socket.close();

    }
}
